package com.event.demo.service;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author hh
 * @since 2023/3/29
 */
@Component
public class MessageListener implements ApplicationListener<UserChangePasswordEvent> {

    @Override
    public void onApplicationEvent(UserChangePasswordEvent event) {
        // 监听器默认是同步执行的
        System.out.println("实现ApplicationListener收到事件：" + event);
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

}
